
<html>
	<head>
		<title>uploadpbcfile.html</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
		<link href="../../css/general1.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../../script/prototype.js"></script>
		<script type="text/javascript" src="../../script/code.js"></script>
		<script type="text/javascript" src="/vchzms-hiaward/dwr/engine.js"> </script>
		<script type="text/javascript" src="/vchzms-hiaward/dwr/util.js"> </script>
		<script type="text/javascript"
			src="/vchzms-hiaward/dwr/interface/UploadPbcFileDwrAction.js"></script>
			<script type="text/javascript"
			src="/vchzms-hiaward/dwr/interface/OperatePbcFileDwrAction.js"></script>
		<script type="text/javascript">
	  var timeid="";
	  var pid=null;
	  function progress(){
       $('progress').innerHTML=timeid;
       timeid=timeid+"|";
       pid=setTimeout("progress();",40);
       if(timeid.length>155){
        timeid="";
       }
      }
      function encodeContent(content){
         var commandId=3001;
         var restr=DOcxtest1.Zms(commandId,content);
         return restr;
      }
      function pretreatPbcFile(){
       OperatePbcFileDwrAction.pretreatPbcFile(1,function(data){
                alert("预处理成功!");
       });
      
      }
      function subForm(){
        var localUrl=window.location.href;
        var pos=localUrl.indexOf('=');
        var param=localUrl.substring(pos+1);
        alert(param);
        var fso=new ActiveXObject("Scripting.FileSystemObject");
        var filepath=$('filepath').value;
        var file=fso.GetFile(filepath);
        var fileName=file.name;
        var filesize=file.size;
        alert(filesize);
        if(filesize>3145728){
         clearTimeout(pid);
         $('progress').innerHTML=""; 
         alert("文件超过规定大小，无法上传");
        }else{
            progress();
	        var f=fso.OpenTextFile(filepath,1,false,-1);
		    te=f.ReadAll();
		    var rete=encodeContent(filepath);
		    alert(rete);
		    alert(rete.length);
		    UploadPbcFileDwrAction.operate(rete,param,fileName,function(data){
	            if(data.errorMessage!=null&&data.errorMessage.length>0){
	               $('message').innerHTML=data.errorMessage;
	               clearTimeout(pid);
	               $('progress').innerHTML="";
	               alert(data.errorMessage);
	            }else{
	               clearTimeout(pid);
	               $('progress').innerHTML="";
	               $("message").innerHTML="<table class='tablist1'><tr><td colspan='2' class='title2'>总记录数</td><td colspan='2' class='title2'>"+data.total+"</td></tr><tr><td colspan='2' class='title2'>解析成功记录数</td><td colspan='2' class='title2'>"+data.successful+"</td><td><a href='listsuccessfulpbcdata.html?subno=shanghai'><image src='pic/ico/chaxun.gif'></a></td></tr><tr><td colspan='2' class='title2'>解析失败记录数</td><td colspan='2' class='title2'>"+data.fail+"</td><td><a href='listparsedfailpbcdata.html?subno="+param+"'><image src='pic/ico/chaxun.gif'></a></td></tr><tr><td colspan='5'><button class='btn1' onclick='pretreatPbcFile()'>发起预处理</button></td></tr></table>";
	            }
	        }
	        //DEREngine.setVerb=function('POST');
	        ); 
        } 
      }
      
    </script>
	</head>
	<body>
		<div style="top: 140px; left: 250px; position: absolute">
			<table class='tablist1'>
				<tr>
					<td colspan="2" class="title2">
						<object id="DOcxtest1" name="DOcxtest1" on
							classid="clsid:D0746E66-AABA-4D70-91B0-33AD96445826" width=0
							height=0 align=middle hspace=0 vspace=0 viewastext>
						</object>
						人行文件解读
					</td>
				</tr>
				<tr>
					<td>
						选择人行文件
					</td>
					<td>
						<span id=""><input id="filepath" name="filepath"
								type="file" class='btn1' /> </span>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<button class="btn1" onclick="subForm()">
							解读
						</button>
						&nbsp;
						<button class="btn1" onclick="">
							无人行文件
						</button>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<span id="progress"></span>
					</td>
				</tr>
			</table>
			<span id="message"></span>
		</div>
	</body>
</html>
